/*
 * @Description: 
 * @Author: 赵大壮
 * @Date: 2021-12-06 17:18:37
 * @LastEditTime: 2021-12-06 17:36:29
 * @LastEditors: 赵大壮
 */
import dzMsgBox from "@/utils/DZMessageBox";
import { Component, Vue, Inject } from "vue-property-decorator";
import DZModelTemplate from "../../model/DZModelTemplate";
import DZServiceInves from "../../service/DZServiceInves";
import UiDialogTemplateInfo from "@/components/ui-dialog/UiDialogTemplateInfo.vue"
import UiDialogTemplateEditName from "@/components/ui-dialog/UiDialogTemplateEditName.vue"

@Component({
    components: { UiDialogTemplateInfo , UiDialogTemplateEditName}
})
export default class Index extends Vue {

    s_inves = new DZServiceInves();

    dialog_template_info = false;

    dialog_template_edit = false;

    m_model_template = new DZModelTemplate();

    created() {
        this.action_list_template();
    }

    mounted() {

    }

    beforeDestroy() {

    }

    action_list_template() {
        this.s_inves.net_list_template_question();

    }
    action_page_base_info(templateId) {
        this.$router.push({ path: '/question/list', query: { templateId: templateId } })
    }

    action_details_template(item: DZModelTemplate) {
        this.s_inves.m_template_question = JSON.parse(JSON.stringify(item))
        this.s_inves.template_id = item.id
        this.dialog_template_info = true;
    }

    //编辑模板名称
    action_edit_template_name(data) {
        this.m_model_template = Object.assign({},data)
        this.dialog_template_edit = true
    }

    action_update_template(data){
        this.s_inves.net_edit_template_question_name(data.id,data.name,() => {
            this.action_list_template();
        });
    }

    action_del_template(id: string) {
        this.s_inves.m_template_question.id = id;
        dzMsgBox.del("是否删除该模板？", () => {
            this.s_inves.net_del_template_question(() => {
                this.action_list_template();
            });
        })
    }

    action_page_change(current) {
        this.s_inves.m_page.page = current;
        this.action_list_template();
    }



}